/* Linduino Arduino emmulation library for linux
 * @author: Ralph Doncaster
 * @version: $Id:$
 */

#ifndef _WIRING_H_
#define _WIRING_H_

#include <stdint.h>
#include <sys/io.h>

#define lpt_base 0x0378          /* printer port base address */

enum HighVal {HIGH = 1};
enum LowVal {LOW = 0};

void pinMode(uint8_t, uint8_t) {} /* do nothing */

inline void digitalWrite(uint8_t val, LowVal )
{
	int data = inb(lpt_base);
	outb (data & ~(1 << val), lpt_base);
}

inline void digitalWrite(uint8_t val, HighVal )
{
	int data = inb(lpt_base);
	outb (data | (1 << val), lpt_base);
}

/* non-overloaded version */
void digitalWrite(uint8_t, uint8_t );

inline int digitalRead(uint8_t pin)
{
	int data = inb(lpt_base);
	return ( data & (1 << pin) ? 1 : 0 ); 
}

#endif /* _WIRING_H_ */

